<!DOCTYPE html>
<html >
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">
	<meta name="apple-wap-web-app-capable" content="yes">
	<meta name="apple-wap-web-app-status-bar-style" content="black-translucent">
	<title>购物车 </title>
	<script src="common/js/cart/jquery-1.10.2.min.js"></script>
	<link rel="stylesheet" href="common/css/cart/ionic.min.css">
	<link rel="stylesheet" href="common/css/cart/main.css">
	<link rel="stylesheet" href="common/css/cart/share.css">
	<link rel="stylesheet" href="common/css/cart/signin.css">
	<link rel="stylesheet" href="common/css/cart/weixin.css">
	<script src="common/js/cart/cart.js"></script>
	<script src="common/js/cart/ionic.bundle.min.js"></script>
	<script src="common/js/cart/runend.js"></script>
	<script src="common/js/AjaxJson.js"></script>
	<link rel="stylesheet" href="common/css/layui.css">
	<link rel="stylesheet" href="common/font/iconfont.css">
	<link rel="stylesheet" href="common/css/demo.css">
	<script src="common/font/iconfont.js"></script>

	<script type="text/javascript">
//定义全局变量
var i=0;

//金额总和
var money=0;

//计算合计价格
var cart_money={};

//全部商品ID
var cart_id={};
//备份商品ID，用于全选后去掉全选又再次全选
var cart_id_copy={};

</script>
	<link rel="stylesheet" href="common/css/style.css">

</head>
<body>
<div>
<header class="zyw-header">
	<div class="zyw-container white-color">
		<div class="head-l">
			<a href="javascript:window.history.back(-1)" target="_self"><img src="common/images/head-return.svg" alt=""></a>
		</div>
		<div class="head-r">
			<a id="rem_s" href="javascript:void(0)" style="font-size:18px;color: #f0ffff"><font>编辑</font></a>
		</div>
		<!--<h1><a href="#" class="active">商品</a><a href="#item-precent">详情</a><a href="">评价</a></h1>-->
		<!--<div class="head-r"><img src="img/svg/head-more.svg" alt=""></div>-->
	</div>
</header>
	<div style="height:44px;"></div>
	
<div  id="cart_form" >
		<!--list-->

		<!--商品列表-->
		<div class="commodity_box">
			<div class="commodity_list">
                <ul class="commodity_list_term">

                </ul>
			</div>
		</div>
	<!-- end -->

	<!-- footer -->
	<div style="height:55px;"></div>
	<div class="settle_box">
    	<dl class="all_check select">
        	<!--<dt><span id="all_pitch_on" onclick="seleAll()"></span><em>全选</em></dt>-->
        </dl>
        <dl class="total_amount">
        	<dt>总共应付押金：<p id="total_price">¥<b>0</b></p></dt>
        </dl>
        <input type="hidden" name="gcs" id="gcs" />
        <a class="settle_btn" href="javascript:void(0);" id="confirm_cart" onclick="submitOrder()">支付押金</a>
        <a class="settle_btn" href="javascript:void(0);" id="confirm_cart1" onclick="remove()">删除</a>
    </div>
    <!-- end -->
</div>
    <div style="height:30px;"></div>
	<footer class="aui-footer">
		<a href="index.html" class="aui-tabBar-item">
                    <span class="aui-tabBar-item-icon">
                        <!--<i class="icon icon-index"></i>-->
						<!--<i class="layui-icon" style="color: #1E9FFF;">&#xe68e;</i>-->
						<li class="dib">
                            <span class="icon iconfont">&#xe73d;</span>
                        </li>
                        <!--<li class="dib">
                            <svg class="icon svg-icon" aria-hidden="true">
                                <use xlink:href="#icon-shouye"></use>
                            </svg>
                        </li>-->
                    </span>
			<span class="aui-tabBar-item-text">首页</span>
		</a>
		<a href="rentCart.html" class="aui-tabBar-item ">
                    <span class="aui-tabBar-item-icon">
                        <!--<i class="icon icon-cart"></i>-->
						<!--<i class="layui-icon">&#xe657;</i>-->
                        <!--<li class="dib">
                            <span class="icon iconfont">&#xe750;</span>
                        </li>-->
						<li class="dib">
                            <svg class="icon svg-icon" aria-hidden="true">
                                <use xlink:href="#icon-gouwu"></use>
                            </svg>
                        </li>
                    </span>
			<span class="aui-tabBar-item-text">购物车</span>
		</a>
		<a href="orderDetail.html" class="aui-tabBar-item ">
                    <span class="aui-tabBar-item-icon">
                        <!--<i class="icon icon-order"></i>-->
						<!--<i class="layui-icon">&#xe60a;</i>-->
                        <li class="dib">
                            <span class="icon iconfont">&#xe749;</span>
                        </li>
						<!--<li class="dib">
                            <svg class="icon svg-icon" aria-hidden="true">
                                <use xlink:href="#icon-dingdan"></use>
                            </svg>
                        </li>-->
                    </span>
			<span class="aui-tabBar-item-text">订单</span>
		</a>
		<a href="personal.html" class="aui-tabBar-item ">
                    <span class="aui-tabBar-item-icon">
                        <!--<i class="icon icon-home"></i>-->
						<!--<i class="layui-icon">&#xe770;</i>-->
                        <li class="dib">
                            <span class="icon iconfont">&#xe743;</span>
                        </li>
						<!--<li class="dib">
                            <svg class="icon svg-icon" aria-hidden="true">
                                <use xlink:href="#icon-wode"></use>
                            </svg>
                        </li>-->
                    </span>
			<span class="aui-tabBar-item-text">个人中心</span>
		</a>

	</footer>
</div>
     
     
     <script>
       var noX = 0;  /* 没选中时点击加减计算数量  */
       var allThis = $(".commodity_box .select em"); /*底部全选*/
  		/* 减  */
  		function reduceMod(e,totalH,mod,noX){
  			var tn = e.siblings().find(".rent_money").text(); /* 当前选中商品  */
  		//	var tn1 = e.siblings().find(".zi").text(); /* 商品数量  */
  			if(mod != 2){
  				var Total = parseFloat(totalH) - parseFloat(tn);	/* 总价格减该商品总数价格  */
  	  			$("#total_price b").text(Total.toFixed(2));
  			}else{
  				/* 合计加单价-1 */
  				var Total = parseFloat(totalH) - parseFloat(tn);	/* 总价格减该商品总数价格  */
  	  			$("#total_price b").text(Total.toFixed(2));
  			}

}
       /* 加  */
  		function plusMod(e,totalH,mod){

  			var tn = e.siblings().find(".rent_money").text(); /* 当前选中商品  */
  			//var tn1 = e.siblings().find(".zi").text(); /* 商品数量  */
			//alert(mod);
  			if(mod != 2){
  				var Total = parseFloat(totalH) + parseFloat(tn);	/* 总价格加上该商品总数价格  */
                //alert(Total);
  	  			$("#total_price b").text(Total.toFixed(2));

  			}else{
  				/* 合计加单价+1 */
  				var Total = parseFloat(totalH)+(parseFloat(tn)+(noX-1));	/* 总价格加上该商品总数价格  */
                //alert(Total.toFixed(2));
  	  			$("#total_price b").text(Total.toFixed(2));
  			}

}
       /*/!*全选该店商品价格 加*!/
  		function commodityPlusMod(e,totalH){
  			var qu = e.parents(".commodity_list").find(".pitch_on").parent().find(".qu_su");
			var quj = e.parents(".commodity_list").find(".pitch_on").parent().find(".zi");
			var Total = 0;
			var erTotal = true;
			/!* 该商品全部金额  *!/
			for(var i=0; i<qu.length; i++)
				{
					var n = qu.eq(i).text();
					var n1 = quj.eq(i).text();
					/!*合计价格*!/
					if(erTotal){
						Total = parseFloat(totalH) +(parseFloat(n)*parseFloat(n1));
						if(Total < 0)
							Total=0;
						erTotal = false;
					}else{
						Total = parseFloat(Total) + (parseFloat(n)*parseFloat(n1));
						if(Total < 0)
							Total=0;
					}
				}
			$("#total_price b").text(Total.toFixed(2)); /!* 合计金额  *!/
        }
       var plus;
  		/!*全选该店商品价格 减*!/
  		function commodityReduceMod(e,totalH){
  			var qu = e.parents(".commodity_list").find(".pitch_on").parent().find(".qu_su");
			var quj = e.parents(".commodity_list").find(".pitch_on").parent().find(".zi");
			var Total = 0;
			
			var erTotal = true;
			/!* 该商品全部金额  *!/
			for(var i=0; i<qu.length; i++)
				{
					var n = qu.eq(i).text();
					var n1 = quj.eq(i).text();
					/!*合计价格*!/
					if(erTotal){
						Total = parseFloat(totalH) - (parseFloat(n)*parseFloat(n1));
						plus = parseFloat(n)*parseFloat(n1);
						if(Total < 0)
							Total=0;
						erTotal = false;
					}else{
						Total = parseFloat(Total) - (parseFloat(n)*parseFloat(n1));
						plus = parseFloat(n)*parseFloat(n1);
						if(Total < 0)
							Total=0;
					}
					
					$("#total_price b").text(Total.toFixed(2)); /!* 合计金额  *!/
				}
			
			return plus;
        }*/
       /*全部商品价格*/
  		function commodityWhole() {
  			/* 合计金额  */
			var je = $(".commodity_box .select .rent_money"); /* 全部商品单价  */
		//	var je1 = $(".commodity_box .select .zi");  /* 全部商品数量  */
			var TotalJe = 0;
			for(var i=0; i<je.length; i++)
			{
				var n = je.eq(i).text();
		//		var n1 = je1.eq(i).text();
		//		TotalJe = TotalJe + (parseFloat(n)*parseFloat(n1));
				TotalJe += parseFloat(n);
				
			}
			$("#total_price b").text(TotalJe.toFixed(2)); /* 合计金额  */
        }
       /*//选择结算商品

       $(".select em").click(function(){
           alert("点击了!!");
           var su = $(this).attr("aem");
           var carts_id=$(this).attr("cart_id");
           var totalH = $("#total_price b").text(); /!* 合计金额  *!/
           if(su == 0){
               /!* 单选商品  *!/
               if($(this).hasClass("pitch_on")){
                   /!*去该店全选*!/
                   $(this).parents("ul").siblings(".select").find("em").removeClass("pitch_on");
                   /!*去底部全选*!/
                   $("#all_pitch_on").removeClass("pitch_on");
                   $(this).removeClass("pitch_on");
                   reduceMod($(this),totalH);
                   cart_id[carts_id]="";
                   delete cart_id[carts_id];
               }else{
                   $(this).addClass("pitch_on");
                   var n = $(this).parents("ul").children().find(".pitch_on");
                   var n1 = $(this).parents("ul").children();
                   plusMod($(this),totalH,0,noX);
                   cart_id[carts_id]="";
                   /!*该店商品全选中时*!/
                   if(n.length == n1.length){
                       $(this).parents("ul").siblings(".select").find("em").addClass("pitch_on");
                   }
                   /!*商品全部选中时*!/
                   var fot = $(".commodity_list_box .tite_tim .pitch_on");
                   var fot1 = $(".commodity_list_box .tite_tim em");
                   if(fot.length == fot1.length)
                   $("#all_pitch_on").addClass("pitch_on");
               }
           }else{
               /!* 全选该店铺  *!/
               if($(this).hasClass("pitch_on")){
                   /!*去底部全选*!/
                   $("#all_pitch_on").removeClass("pitch_on");
                   $(this).removeClass("pitch_on");

                   commodityReduceMod($(this),totalH);
                   $(this).parent().siblings("ul").find("em").removeClass("pitch_on");
                   delete cart_id[carts_id];
               }else{
                   commodityReduceMod($(this),totalH);

                   $(this).addClass("pitch_on");

                   $(this).parent().siblings("ul").find("em").addClass("pitch_on");

                   if(plus != NaN && plus != undefined){
                       totalH = parseFloat(totalH)-parseFloat(plus);
                   }

                   commodityPlusMod($(this),totalH);
                 cart_id[carts_id]="";
                 /!*商品全部选中时*!/
                   var fot = $(".commodity_list_box .tite_tim .pitch_on");
                   var fot1 = $(".commodity_list_box .tite_tim em");
                   if(fot.length == fot1.length)
                   $("#all_pitch_on").addClass("pitch_on");

               }
           }

           //计算选择数值
           number();

       });	*/
  		/* 底部全选  */
  		
  		var bot = 0;


  		$("#all_pitch_on").click(function(){
  			if(bot == 0){
  				$(this).addClass("pitch_on");
  				allThis.removeClass("pitch_on");
  				allThis.addClass("pitch_on");
  				/*总价格*/
  				commodityWhole();
  				bot = 1;
  				//重新加入属性对象
  				for(var key in cart_id_copy){
  					cart_id[key]="";
  				}
  			}else{
  				$(this).removeClass("pitch_on");
  				allThis.removeClass("pitch_on");
  				$("#total_price b").text("0");
  				bot = 0;
  				//移除全部对象
  				for(var key in cart_id){
  					delete cart_id[key];
  				}
  			}
  			//计算选择数值
  			number();
  		});
  		
  		function number() {
  			var num=0;
  			for(var key in cart_id){
					num++;
				}
  			//将选择的放入到计算里面
  			//$("#confirm_cart").html("结算("+num+")");
		}
  		
  		/* 编辑商品  */
  		var topb = 0;
  		$("#rem_s").click(function(){
  			if(topb == 0){
  				$(this).text("完成");
  				$(".total_amount").hide(); /* 合计  */
  				$("#confirm_cart").hide(); /* 结算  */
  				$("#confirm_cart1").show(); /* 删除 */
  				topb = 1;
  			}else{
  				topb = 0;
  				$(this).text("编辑");
  				$(".total_amount").show(); /* 合计  */
  				$("#confirm_cart").show(); /* 结算  */
  				$("#confirm_cart1").hide(); /* 删除 */
  				allThis.removeClass("pitch_on"); /* 取消所有选择  */
  				$("#all_pitch_on").removeClass("pitch_on"); /* 取消所有选择  */
  				$("#total_price b").text("0"); /*合计价格清零*/

  			}
  			
  		});
		/*/!* 加减  *!/
		
		function reducew(obj){
			//减

			var $this = $(obj);
			var totalH = $("#total_price b").text(); /!* 合计金额  *!/
			var ise = $this.siblings("span").text();
			var gc_id = $this.siblings("input").val();
			if(noX <= 0){
				noX = 0;
			}else{
				noX--;
            }
            if(parseInt(ise) <= 1){
				$this.siblings("span").text("1");
			}else{
				var n =parseInt(ise)-1;
				$this.siblings("span").text(n);
				if($this.parent().parent().children("em").hasClass("pitch_on")){
					var mo = $this.parent().parent().children("em");
					reduceMod(mo,totalH,2,noX);
					noX=0;
				}
				
			}
			
			goods_count_adjust(gc_id,n,null);
        }
       function plusw(obj){
			//加
			var $this = $(obj);
			var totalH = $("#total_price b").text(); /!* 合计金额  *!/
			var ise = $this.siblings("span").text();
			var gc_id = $this.siblings("input").val();
			var n =parseInt(ise)+1;
			noX++;
			
			$this.siblings("span").text(n);
			if($this.parent().parent().children("em").hasClass("pitch_on")){
				var mo = $this.parent().parent().children("em");
				plusMod(mo,totalH,2,noX);
				noX=0;
			}
			
			goods_count_adjust(gc_id,n,null);
		}*/
		
		
		 //删除 
		/*function big_cart_remove(){
			$(".commodity_list_term .pitch_on").parent().remove();
			$(".commodity_list .tite_tim > em.pitch_on").parents(".commodity_box").remove();	
		}*/
		 
	</script>
</body>
</html>